<?php
namespace app\admin\model;
use think\facade\Log;
use think\Model;

class AdminMenu extends Model
{
    /**
     * 获取菜单 + 用户信息
     * @return array
     */
    public static function getMenu()
    {
        $model = new self();
        //超级管理员以外的
        if(AdminId() != 1111111){
            // 查询我所在的角色组
            $user = Admin::where('id',AdminId())->find();
            if(empty($user)){
                return false;
            }
            $role = [];
            // 循环我的权限
            foreach ($user['roles'] as $k=>$r){
                $role = array_merge($role,$r['roles']);
            }
            $model = $model->where('id','in',$role);
        }
        // 根据权限查询菜单
        $list = $model->where('status',1)->order('sort_order asc')->select();
        //$data = list_to_tree(collection($list)->toArray());
        return $list;
    }




}